$themes: (
  day: (
    //背景色
      html-color: $html-background-day,
    //背景色
      background-color: $body-background-day,
    // 主文本色
      text-color: $text-color-day,
    // 选中颜色
      active-color: $active-color-day,
    // 字体图标颜色
      icon-color: $icon-color-day
  ),
  night: (
    //背景色
      html-color: $html-background-night,
    //背景
      background-color: $body-background-night,
    // 主文本色
      text-color: $text-color-night,
    // 选中颜色
      active-color: $active-color-night,
    // 字体图标颜色
      icon-color: $icon-color-night
  )
);

@mixin themeify {
  @each $theme-name, $theme-map in $themes {
    //!global 把局部变量强升为全局变量
    $theme-map: $theme-map !global;
    //判断html的data-theme的属性值  #{}是sass的插值表达式
    //& sass嵌套里的父容器标识   @content是混合器插槽，像vue的slot
    [data-theme='#{$theme-name}'] & {
      @content;
    }
  }
}

//声明一个根据Key获取颜色的function
@function themed($key) {
  @return map-get($theme-map, $key);
}

//获取背景颜色
@mixin background-color($color) {
  @include themeify {
    background: themed($color);
  }
}
//获取html背景颜色
@mixin html-color($color) {
  @include themeify {
    background: themed($color);
  }
}
//获取字体颜色
@mixin font-color($color) {
  @include themeify {
    color: themed($color);
  }
}

//获取选中颜色
@mixin active-color($color) {
  @include themeify {
    color: themed($color);
  }
}

//获取字体图标颜色
@mixin icon-color($color) {
  @include themeify {
    color: themed($color);
  }
}
